#!/bin/bash

datetime=$(date +%Y-%m-%d-%H_%M_%S)

MYSQL=$(docker ps| grep "mysql:5.6" | grep -v grep | awk '{print $1}')

backup_path=/home/backup/sql

MYSQL_DEV_USERNAME=dev

MYSQL_DEV_PASSWORD=123qwe

docker exec ${MYSQL} sh -c "exec mysqldump -u$MYSQL_DEV_USERNAME -p$MYSQL_DEV_PASSWORD ciis " > ${backup_path}/${datetime}_all-databases.sql

find ${backup_path} -mtime +10 -name "*.sql" -exec rm -rf {} \;
